package com.crm.dao;

import java.util.ArrayList;
import java.util.List;

import com.crm.dao.core.BaseDao;
import com.crm.pojo.Tasks;
import com.crm.pojo.User;
import com.crm.util.DateUtil;

public class TasksDao extends BaseDao<Tasks, String	>{

	public List<Tasks> tasksList = new ArrayList<Tasks>();
	public List<Tasks> todayList = new ArrayList<Tasks>() ;
	public List<Tasks> threeDayList = new ArrayList<Tasks>();
	
	public List<Tasks> findListByUser(User user){
			
			return tasksList = findBy("user",user);
		}
	public List<Tasks> findTodayList(User user){
		
		tasksList = findBy("user",user);
		
		if(todayList.isEmpty()){
			for(Tasks t:tasksList){		
				if(DateUtil.lastTime(t.getFinishTime())==0 && !t.getIsFinished()){
				
					todayList.add(t);
				}
			}
		}
		return todayList;
	}
	public List<Tasks> findThreeDayList(User user){
		
		tasksList = findBy("user",user);
		if(threeDayList.isEmpty()){
			for(Tasks t:tasksList){
				if(DateUtil.lastTime(t.getFinishTime())>0 && DateUtil.lastTime(t.getFinishTime())<2 && !t.getIsFinished()){
					threeDayList.add(t);
				}
			}
		}
		return threeDayList;
	}
	//get&set
	public List<Tasks> getTasksList() {
		return tasksList;
	}
	public void setTasksList(List<Tasks> tasksList) {
		this.tasksList = tasksList;
	}
	public List<Tasks> getTodayList() {
		return todayList;
	}
	public void setTodayList(List<Tasks> todayList) {
		this.todayList = todayList;
	}
	public List<Tasks> getThreeDayList() {
		return threeDayList;
	}
	public void setThreeDayList(List<Tasks> threeDayList) {
		this.threeDayList = threeDayList;
	}
}
